IF OBJECT_ID (N'dbo.GetCfgCtrlKeyAsVarchar30', N'FN') IS NOT NULL
     DROP FUNCTION dbo.GetCfgCtrlKeyAsVarchar30
GO

CREATE FUNCTION dbo.GetCfgCtrlKeyAsVarchar30
     ( @CfgCtrlKey varchar(30) )
RETURNS varchar(30)
AS
/*
 *
 * GetCfgCtrlKeyAsVarchar30
 *
 * Purpose:      
 *
 * Inputs:       
 *
 * Assumes:      
 *
 * Effects:      
 *
 * Returns:      
 *
 * Note(s):      
 *
 * Author(s):    NOVA Concepts Ltd.
 *
 * Change Log:   Initial Release, 06/04/2009, 1.00.0000
 *
 */
BEGIN
     DECLARE @ReturnValue varchar(30)

     -- Get the value and force it into 30 characters     
     SELECT @ReturnValue = CONVERT( varchar(30), CfgCtrlValue )
     FROM   dbo.CfgCtrl
     WHERE  CfgCtrlKey = @CfgCtrlKey

     RETURN @ReturnValue
END
GO
